﻿using System;
using System.ServiceModel;
using System.Windows.Forms;
using NHEntity;
using NHServices.Contracts;

namespace NHClient.Windows
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void FormMain_Load(object sender, EventArgs e)
        {
            try
            {
                var userFactory = new ChannelFactory<IUserService>("UserEndPoint");
                var userService = userFactory.CreateChannel();
                var users = userService.FindAll();
                dataGridView1.DataSource = users;

                var roleFactory = new ChannelFactory<IRoleService>("RoleEndPoint");
                var roleService = roleFactory.CreateChannel();
                var roles = roleService.FindAll();

                //var entity = new UserEntity {Login = "KarlosRoj", Password = "Kr"};
                //userService.Save(entity);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
    }
}
